<?php
// require the general classes.
// they won't be required anywhere else but this script
require_once ("general_classes/loader.php");
require_once ("general_classes/basecontroller.php");
require_once ("general_classes/basemodel.php");
// require_once ("library/logger.php");

if (! defined ( 'BASE_PATH' )) {
	define ( 'BASE_PATH', dirname ( __FILE__ ) . '/' );
}
if (! defined ( 'CHUNKS_PATH' )) {
	define ( 'CHUNKS_PATH', BASE_PATH . 'chunks/' );
}
if (! defined ( 'CONTENT_PATH' )) {
	define ( 'CONTENT_PATH', BASE_PATH . 'content/' );
}
if (! defined ( 'MODELS_PATH' )) {
	define ( 'MODELS_PATH', BASE_PATH . 'models/' );
}
if (! defined ( 'CONTROLLERS_PATH' )) {
	define ( 'CONTROLLERS_PATH', BASE_PATH . 'controllers/' );
}
if (! defined ( 'LIBRARY_PATH' )) {
	define ( 'LIBRARY_PATH', BASE_PATH . 'library/' );
}
if (! defined ( 'DB_FILENAME' )) {
	define ( 'DB_FILENAME', dirname ( __FILE__ ) . '/database/wordage.db' );
}

set_include_path ( '.' );
set_include_path ( get_include_path () . PATH_SEPARATOR . CHUNKS_PATH );
set_include_path ( get_include_path () . PATH_SEPARATOR . CONTENT_PATH );
set_include_path ( get_include_path () . PATH_SEPARATOR . MODELS_PATH );
set_include_path ( get_include_path () . PATH_SEPARATOR . CONTROLLERS_PATH );
set_include_path ( get_include_path () . PATH_SEPARATOR . LIBRARY_PATH );
spl_autoload_register ();

date_default_timezone_set ( 'Europe/Vilnius' );
define ( 'DEBUG', TRUE );

error_reporting (E_ALL);
ini_set ( 'log_errors', '1' );
ini_set ( 'display_errors', '1' );
ini_set ( 'error_log', 'logs/errors.log' );

$loader = new Loader ( $_GET, $_POST );
$controller = $loader->CreateController ();
$controller->ExecuteAction();